package inventorysystem.dao;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;


/**
 * This class was autogenerated by Torque on:
 *
 * [Wed Mar 03 16:45:55 CST 2010]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to User
 */
public abstract class BaseUser extends BaseObject
{
    /** The Peer class */
    private static final UserPeer peer =
        new UserPeer();

        
    /** The value for the user_ID field */
    private int user_ID;
      
    /** The value for the employeeNumber field */
    private String employeeNumber;
      
    /** The value for the firstName field */
    private String firstName;
      
    /** The value for the middleName field */
    private String middleName;
      
    /** The value for the lastName field */
    private String lastName;
      
    /** The value for the userName field */
    private String userName;
      
    /** The value for the password field */
    private String password;
      
    /** The value for the contactNumber field */
    private String contactNumber;
      
    /** The value for the division field */
    private String division;
      
    /** The value for the type field */
    private String type;
      
    /** The value for the status field */
    private boolean status;
  
    
    /**
     * Get the User_ID
     *
     * @return int
     */
    public int getUser_ID()
    {
        return user_ID;
    }

                                              
    /**
     * Set the value of User_ID
     *
     * @param v new value
     */
    public void setUser_ID(int v) throws TorqueException
    {
    
                  if (this.user_ID != v)
              {
            this.user_ID = v;
            setModified(true);
        }
    
          
                                  
        // update associated Manages
        if (collManagess != null)
        {
            for (int i = 0; i < collManagess.size(); i++)
            {
                ((Manages) collManagess.get(i))
                    .setUser_ID(v);
            }
        }
                                          
        // update associated ORF
        if (collORFs != null)
        {
            for (int i = 0; i < collORFs.size(); i++)
            {
                ((ORF) collORFs.get(i))
                    .setUser_ID(v);
            }
        }
                                          
        // update associated ORF_Supply
        if (collORF_Supplys != null)
        {
            for (int i = 0; i < collORF_Supplys.size(); i++)
            {
                ((ORF_Supply) collORF_Supplys.get(i))
                    .setUser_ID(v);
            }
        }
                      }
  
    /**
     * Get the EmployeeNumber
     *
     * @return String
     */
    public String getEmployeeNumber()
    {
        return employeeNumber;
    }

                        
    /**
     * Set the value of EmployeeNumber
     *
     * @param v new value
     */
    public void setEmployeeNumber(String v) 
    {
    
                  if (!ObjectUtils.equals(this.employeeNumber, v))
              {
            this.employeeNumber = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the FirstName
     *
     * @return String
     */
    public String getFirstName()
    {
        return firstName;
    }

                        
    /**
     * Set the value of FirstName
     *
     * @param v new value
     */
    public void setFirstName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.firstName, v))
              {
            this.firstName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the MiddleName
     *
     * @return String
     */
    public String getMiddleName()
    {
        return middleName;
    }

                        
    /**
     * Set the value of MiddleName
     *
     * @param v new value
     */
    public void setMiddleName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.middleName, v))
              {
            this.middleName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the LastName
     *
     * @return String
     */
    public String getLastName()
    {
        return lastName;
    }

                        
    /**
     * Set the value of LastName
     *
     * @param v new value
     */
    public void setLastName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.lastName, v))
              {
            this.lastName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the UserName
     *
     * @return String
     */
    public String getUserName()
    {
        return userName;
    }

                        
    /**
     * Set the value of UserName
     *
     * @param v new value
     */
    public void setUserName(String v) 
    {
    
                  if (!ObjectUtils.equals(this.userName, v))
              {
            this.userName = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Password
     *
     * @return String
     */
    public String getPassword()
    {
        return password;
    }

                        
    /**
     * Set the value of Password
     *
     * @param v new value
     */
    public void setPassword(String v) 
    {
    
                  if (!ObjectUtils.equals(this.password, v))
              {
            this.password = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the ContactNumber
     *
     * @return String
     */
    public String getContactNumber()
    {
        return contactNumber;
    }

                        
    /**
     * Set the value of ContactNumber
     *
     * @param v new value
     */
    public void setContactNumber(String v) 
    {
    
                  if (!ObjectUtils.equals(this.contactNumber, v))
              {
            this.contactNumber = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Division
     *
     * @return String
     */
    public String getDivision()
    {
        return division;
    }

                        
    /**
     * Set the value of Division
     *
     * @param v new value
     */
    public void setDivision(String v) 
    {
    
                  if (!ObjectUtils.equals(this.division, v))
              {
            this.division = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Type
     *
     * @return String
     */
    public String getType()
    {
        return type;
    }

                        
    /**
     * Set the value of Type
     *
     * @param v new value
     */
    public void setType(String v) 
    {
    
                  if (!ObjectUtils.equals(this.type, v))
              {
            this.type = v;
            setModified(true);
        }
    
          
              }
  
    /**
     * Get the Status
     *
     * @return boolean
     */
    public boolean getStatus()
    {
        return status;
    }

                        
    /**
     * Set the value of Status
     *
     * @param v new value
     */
    public void setStatus(boolean v) 
    {
    
                  if (this.status != v)
              {
            this.status = v;
            setModified(true);
        }
    
          
              }
  
         
                                
            
    /**
     * Collection to store aggregation of collManagess
     */
    protected List collManagess;

    /**
     * Temporary storage of collManagess to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initManagess()
    {
        if (collManagess == null)
        {
            collManagess = new ArrayList();
        }
    }

    /**
     * Method called to associate a Manages object to this object
     * through the Manages foreign key attribute
     *
     * @param l Manages
     * @throws TorqueException
     */
    public void addManages(Manages l) throws TorqueException
    {
        getManagess().add(l);
        l.setUser((User) this);
    }

    /**
     * The criteria used to select the current contents of collManagess
     */
    private Criteria lastManagessCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getManagess(new Criteria())
     *
     * @throws TorqueException
     */
    public List getManagess() throws TorqueException
    {
        if (collManagess == null)
        {
            collManagess = getManagess(new Criteria(10));
        }
        return collManagess;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related Managess from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getManagess(Criteria criteria) throws TorqueException
    {
        if (collManagess == null)
        {
            if (isNew())
            {
               collManagess = new ArrayList();
            }
            else
            {
                      criteria.add(ManagesPeer.USER_ID, getUser_ID() );
                      collManagess = ManagesPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(ManagesPeer.USER_ID, getUser_ID());
                      if (!lastManagessCriteria.equals(criteria))
                {
                    collManagess = ManagesPeer.doSelect(criteria);
                }
            }
        }
        lastManagessCriteria = criteria;

        return collManagess;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getManagess(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getManagess(Connection con) throws TorqueException
    {
        if (collManagess == null)
        {
            collManagess = getManagess(new Criteria(10), con);
        }
        return collManagess;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related Managess from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getManagess(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collManagess == null)
        {
            if (isNew())
            {
               collManagess = new ArrayList();
            }
            else
            {
                       criteria.add(ManagesPeer.USER_ID, getUser_ID());
                       collManagess = ManagesPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(ManagesPeer.USER_ID, getUser_ID());
                       if (!lastManagessCriteria.equals(criteria))
                 {
                     collManagess = ManagesPeer.doSelect(criteria, con);
                 }
             }
         }
         lastManagessCriteria = criteria;

         return collManagess;
     }

                        
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User is new, it will return
     * an empty collection; or if this User has previously
     * been saved, it will retrieve related Managess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in User.
     */
    protected List getManagessJoinUser(Criteria criteria)
        throws TorqueException
    {
        if (collManagess == null)
        {
            if (isNew())
            {
               collManagess = new ArrayList();
            }
            else
            {
                            criteria.add(ManagesPeer.USER_ID, getUser_ID());
                            collManagess = ManagesPeer.doSelectJoinUser(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ManagesPeer.USER_ID, getUser_ID());
                        if (!lastManagessCriteria.equals(criteria))
            {
                collManagess = ManagesPeer.doSelectJoinUser(criteria);
            }
        }
        lastManagessCriteria = criteria;

        return collManagess;
    }
                  
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User is new, it will return
     * an empty collection; or if this User has previously
     * been saved, it will retrieve related Managess from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in User.
     */
    protected List getManagessJoinSupply(Criteria criteria)
        throws TorqueException
    {
        if (collManagess == null)
        {
            if (isNew())
            {
               collManagess = new ArrayList();
            }
            else
            {
                            criteria.add(ManagesPeer.USER_ID, getUser_ID());
                            collManagess = ManagesPeer.doSelectJoinSupply(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ManagesPeer.USER_ID, getUser_ID());
                        if (!lastManagessCriteria.equals(criteria))
            {
                collManagess = ManagesPeer.doSelectJoinSupply(criteria);
            }
        }
        lastManagessCriteria = criteria;

        return collManagess;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collORFs
     */
    protected List collORFs;

    /**
     * Temporary storage of collORFs to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initORFs()
    {
        if (collORFs == null)
        {
            collORFs = new ArrayList();
        }
    }

    /**
     * Method called to associate a ORF object to this object
     * through the ORF foreign key attribute
     *
     * @param l ORF
     * @throws TorqueException
     */
    public void addORF(ORF l) throws TorqueException
    {
        getORFs().add(l);
        l.setUser((User) this);
    }

    /**
     * The criteria used to select the current contents of collORFs
     */
    private Criteria lastORFsCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getORFs(new Criteria())
     *
     * @throws TorqueException
     */
    public List getORFs() throws TorqueException
    {
        if (collORFs == null)
        {
            collORFs = getORFs(new Criteria(10));
        }
        return collORFs;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related ORFs from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getORFs(Criteria criteria) throws TorqueException
    {
        if (collORFs == null)
        {
            if (isNew())
            {
               collORFs = new ArrayList();
            }
            else
            {
                      criteria.add(ORFPeer.USER_ID, getUser_ID() );
                      collORFs = ORFPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(ORFPeer.USER_ID, getUser_ID());
                      if (!lastORFsCriteria.equals(criteria))
                {
                    collORFs = ORFPeer.doSelect(criteria);
                }
            }
        }
        lastORFsCriteria = criteria;

        return collORFs;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getORFs(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getORFs(Connection con) throws TorqueException
    {
        if (collORFs == null)
        {
            collORFs = getORFs(new Criteria(10), con);
        }
        return collORFs;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related ORFs from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getORFs(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collORFs == null)
        {
            if (isNew())
            {
               collORFs = new ArrayList();
            }
            else
            {
                       criteria.add(ORFPeer.USER_ID, getUser_ID());
                       collORFs = ORFPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(ORFPeer.USER_ID, getUser_ID());
                       if (!lastORFsCriteria.equals(criteria))
                 {
                     collORFs = ORFPeer.doSelect(criteria, con);
                 }
             }
         }
         lastORFsCriteria = criteria;

         return collORFs;
     }

                  
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User is new, it will return
     * an empty collection; or if this User has previously
     * been saved, it will retrieve related ORFs from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in User.
     */
    protected List getORFsJoinUser(Criteria criteria)
        throws TorqueException
    {
        if (collORFs == null)
        {
            if (isNew())
            {
               collORFs = new ArrayList();
            }
            else
            {
                            criteria.add(ORFPeer.USER_ID, getUser_ID());
                            collORFs = ORFPeer.doSelectJoinUser(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ORFPeer.USER_ID, getUser_ID());
                        if (!lastORFsCriteria.equals(criteria))
            {
                collORFs = ORFPeer.doSelectJoinUser(criteria);
            }
        }
        lastORFsCriteria = criteria;

        return collORFs;
    }
                            


                          
            
    /**
     * Collection to store aggregation of collORF_Supplys
     */
    protected List collORF_Supplys;

    /**
     * Temporary storage of collORF_Supplys to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initORF_Supplys()
    {
        if (collORF_Supplys == null)
        {
            collORF_Supplys = new ArrayList();
        }
    }

    /**
     * Method called to associate a ORF_Supply object to this object
     * through the ORF_Supply foreign key attribute
     *
     * @param l ORF_Supply
     * @throws TorqueException
     */
    public void addORF_Supply(ORF_Supply l) throws TorqueException
    {
        getORF_Supplys().add(l);
        l.setUser((User) this);
    }

    /**
     * The criteria used to select the current contents of collORF_Supplys
     */
    private Criteria lastORF_SupplysCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getORF_Supplys(new Criteria())
     *
     * @throws TorqueException
     */
    public List getORF_Supplys() throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            collORF_Supplys = getORF_Supplys(new Criteria(10));
        }
        return collORF_Supplys;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related ORF_Supplys from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getORF_Supplys(Criteria criteria) throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            if (isNew())
            {
               collORF_Supplys = new ArrayList();
            }
            else
            {
                      criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID() );
                      collORF_Supplys = ORF_SupplyPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                      criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                      if (!lastORF_SupplysCriteria.equals(criteria))
                {
                    collORF_Supplys = ORF_SupplyPeer.doSelect(criteria);
                }
            }
        }
        lastORF_SupplysCriteria = criteria;

        return collORF_Supplys;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getORF_Supplys(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getORF_Supplys(Connection con) throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            collORF_Supplys = getORF_Supplys(new Criteria(10), con);
        }
        return collORF_Supplys;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User has previously
     * been saved, it will retrieve related ORF_Supplys from storage.
     * If this User is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getORF_Supplys(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            if (isNew())
            {
               collORF_Supplys = new ArrayList();
            }
            else
            {
                       criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                       collORF_Supplys = ORF_SupplyPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                       criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                       if (!lastORF_SupplysCriteria.equals(criteria))
                 {
                     collORF_Supplys = ORF_SupplyPeer.doSelect(criteria, con);
                 }
             }
         }
         lastORF_SupplysCriteria = criteria;

         return collORF_Supplys;
     }

                        
              
                    
                              
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User is new, it will return
     * an empty collection; or if this User has previously
     * been saved, it will retrieve related ORF_Supplys from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in User.
     */
    protected List getORF_SupplysJoinUser(Criteria criteria)
        throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            if (isNew())
            {
               collORF_Supplys = new ArrayList();
            }
            else
            {
                            criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                            collORF_Supplys = ORF_SupplyPeer.doSelectJoinUser(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                        if (!lastORF_SupplysCriteria.equals(criteria))
            {
                collORF_Supplys = ORF_SupplyPeer.doSelectJoinUser(criteria);
            }
        }
        lastORF_SupplysCriteria = criteria;

        return collORF_Supplys;
    }
                  
                    
                    
                                
                                                              
                                        
                    
                    
          
    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this User is new, it will return
     * an empty collection; or if this User has previously
     * been saved, it will retrieve related ORF_Supplys from storage.
     *
     * This method is protected by default in order to keep the public
     * api reasonable.  You can provide public methods for those you
     * actually need in User.
     */
    protected List getORF_SupplysJoinORF(Criteria criteria)
        throws TorqueException
    {
        if (collORF_Supplys == null)
        {
            if (isNew())
            {
               collORF_Supplys = new ArrayList();
            }
            else
            {
                            criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                            collORF_Supplys = ORF_SupplyPeer.doSelectJoinORF(criteria);
            }
        }
        else
        {
            // the following code is to determine if a new query is
            // called for.  If the criteria is the same as the last
            // one, just return the collection.
            boolean newCriteria = true;
                        criteria.add(ORF_SupplyPeer.USER_ID, getUser_ID());
                        if (!lastORF_SupplysCriteria.equals(criteria))
            {
                collORF_Supplys = ORF_SupplyPeer.doSelectJoinORF(criteria);
            }
        }
        lastORF_SupplysCriteria = criteria;

        return collORF_Supplys;
    }
                            


          
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
        if (fieldNames == null)
        {
            fieldNames = new ArrayList();
              fieldNames.add("User_ID");
              fieldNames.add("EmployeeNumber");
              fieldNames.add("FirstName");
              fieldNames.add("MiddleName");
              fieldNames.add("LastName");
              fieldNames.add("UserName");
              fieldNames.add("Password");
              fieldNames.add("ContactNumber");
              fieldNames.add("Division");
              fieldNames.add("Type");
              fieldNames.add("Status");
              fieldNames = Collections.unmodifiableList(fieldNames);
        }
        return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
          if (name.equals("User_ID"))
        {
                return new Integer(getUser_ID());
            }
          if (name.equals("EmployeeNumber"))
        {
                return getEmployeeNumber();
            }
          if (name.equals("FirstName"))
        {
                return getFirstName();
            }
          if (name.equals("MiddleName"))
        {
                return getMiddleName();
            }
          if (name.equals("LastName"))
        {
                return getLastName();
            }
          if (name.equals("UserName"))
        {
                return getUserName();
            }
          if (name.equals("Password"))
        {
                return getPassword();
            }
          if (name.equals("ContactNumber"))
        {
                return getContactNumber();
            }
          if (name.equals("Division"))
        {
                return getDivision();
            }
          if (name.equals("Type"))
        {
                return getType();
            }
          if (name.equals("Status"))
        {
                return new Boolean(getStatus());
            }
          return null;
    }
    
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
          if (name.equals(UserPeer.USER_ID))
        {
                return new Integer(getUser_ID());
            }
          if (name.equals(UserPeer.EMPLOYEENUMBER))
        {
                return getEmployeeNumber();
            }
          if (name.equals(UserPeer.FIRSTNAME))
        {
                return getFirstName();
            }
          if (name.equals(UserPeer.MIDDLENAME))
        {
                return getMiddleName();
            }
          if (name.equals(UserPeer.LASTNAME))
        {
                return getLastName();
            }
          if (name.equals(UserPeer.USERNAME))
        {
                return getUserName();
            }
          if (name.equals(UserPeer.PASSWORD))
        {
                return getPassword();
            }
          if (name.equals(UserPeer.CONTACTNUMBER))
        {
                return getContactNumber();
            }
          if (name.equals(UserPeer.DIVISION))
        {
                return getDivision();
            }
          if (name.equals(UserPeer.TYPE))
        {
                return getType();
            }
          if (name.equals(UserPeer.STATUS))
        {
                return new Boolean(getStatus());
            }
          return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
        {
                return new Integer(getUser_ID());
            }
              if (pos == 1)
        {
                return getEmployeeNumber();
            }
              if (pos == 2)
        {
                return getFirstName();
            }
              if (pos == 3)
        {
                return getMiddleName();
            }
              if (pos == 4)
        {
                return getLastName();
            }
              if (pos == 5)
        {
                return getUserName();
            }
              if (pos == 6)
        {
                return getPassword();
            }
              if (pos == 7)
        {
                return getContactNumber();
            }
              if (pos == 8)
        {
                return getDivision();
            }
              if (pos == 9)
        {
                return getType();
            }
              if (pos == 10)
        {
                return new Boolean(getStatus());
            }
              return null;
    }
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(UserPeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    UserPeer.doInsert((User) this, con);
                    setNew(false);
                }
                else
                {
                    UserPeer.doUpdate((User) this, con);
                }
            }

                                      
                
            if (collManagess != null)
            {
                for (int i = 0; i < collManagess.size(); i++)
                {
                    ((Manages) collManagess.get(i)).save(con);
                }
            }
                                          
                
            if (collORFs != null)
            {
                for (int i = 0; i < collORFs.size(); i++)
                {
                    ((ORF) collORFs.get(i)).save(con);
                }
            }
                                          
                
            if (collORF_Supplys != null)
            {
                for (int i = 0; i < collORF_Supplys.size(); i++)
                {
                    ((ORF_Supply) collORF_Supplys.get(i)).save(con);
                }
            }
                          alreadyInSave = false;
        }
      }


                                          
  
    private final SimpleKey[] pks = new SimpleKey[2];
    private final ComboKey comboPK = new ComboKey(pks);
    
    /**
     * Set the PrimaryKey with an ObjectKey
     *
     * @param key
     */
    public void setPrimaryKey(ObjectKey key) throws TorqueException
    {
        SimpleKey[] keys = (SimpleKey[]) key.getValue();
        SimpleKey tmpKey = null;
                      setUser_ID(((NumberKey)keys[0]).intValue());
                        setContactNumber(keys[1].toString());
              }

    /**
     * Set the PrimaryKey using SimpleKeys.
     *
         * @param int user_ID
         * @param String contactNumber
         */
    public void setPrimaryKey( int user_ID, String contactNumber)
        throws TorqueException
    {
            setUser_ID(user_ID);
            setContactNumber(contactNumber);
        }

    /**
     * Set the PrimaryKey using a String.
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
        setPrimaryKey(new ComboKey(key));
    }
  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
              pks[0] = SimpleKey.keyFor(getUser_ID());
                  pks[1] = SimpleKey.keyFor(getContactNumber());
                  return comboPK;
      }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public User copy() throws TorqueException
    {
        return copyInto(new User());
    }
  
    protected User copyInto(User copyObj) throws TorqueException
    {
          copyObj.setUser_ID(user_ID);
          copyObj.setEmployeeNumber(employeeNumber);
          copyObj.setFirstName(firstName);
          copyObj.setMiddleName(middleName);
          copyObj.setLastName(lastName);
          copyObj.setUserName(userName);
          copyObj.setPassword(password);
          copyObj.setContactNumber(contactNumber);
          copyObj.setDivision(division);
          copyObj.setType(type);
          copyObj.setStatus(status);
  
                    copyObj.setUser_ID(0);
                                                                  copyObj.setContactNumber((String)null);
                              
                                      
                
        List v = getManagess();
        for (int i = 0; i < v.size(); i++)
        {
            Manages obj = (Manages) v.get(i);
            copyObj.addManages(obj.copy());
        }
                                                  
                
        v = getORFs();
        for (int i = 0; i < v.size(); i++)
        {
            ORF obj = (ORF) v.get(i);
            copyObj.addORF(obj.copy());
        }
                                                  
                
        v = getORF_Supplys();
        for (int i = 0; i < v.size(); i++)
        {
            ORF_Supply obj = (ORF_Supply) v.get(i);
            copyObj.addORF_Supply(obj.copy());
        }
                    
        return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public UserPeer getPeer()
    {
        return peer;
    }

    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("User:\n");
        str.append("User_ID = ")
           .append(getUser_ID())
           .append("\n");
        str.append("EmployeeNumber = ")
           .append(getEmployeeNumber())
           .append("\n");
        str.append("FirstName = ")
           .append(getFirstName())
           .append("\n");
        str.append("MiddleName = ")
           .append(getMiddleName())
           .append("\n");
        str.append("LastName = ")
           .append(getLastName())
           .append("\n");
        str.append("UserName = ")
           .append(getUserName())
           .append("\n");
        str.append("Password = ")
           .append(getPassword())
           .append("\n");
        str.append("ContactNumber = ")
           .append(getContactNumber())
           .append("\n");
        str.append("Division = ")
           .append(getDivision())
           .append("\n");
        str.append("Type = ")
           .append(getType())
           .append("\n");
        str.append("Status = ")
           .append(getStatus())
           .append("\n");
        return(str.toString());
    }
}
